/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
angular.module("dataConfig", [])

        .controller("mainController", function($scope) {
            var so = $scope;
            so.config = {};
            so.saveConfig = function() {
                steveConfrim("确定保存吗？", function() {
                    $.post("saveConfig", so.config, function(data) {
                        if (data == 'true') {
                            steveAl("保存成功", 1000);
                        } else {
                            steveAl("保存失败", 1000);
                        }
                    })
                }, true);

            }
            so.getConfig = function() {
                $.post("getConfig", function(data) {
                    so.config = data;
                    if (so.config.autoTask == 'true') {
                        so.config.autoTask = true;
                    }
                    if (so.config.returnReportFlag == 'true') {
                        so.config.returnReportFlag = true;
                    }
                    if (so.config.sendMessageFlag == 'true') {
                        so.config.sendMessageFlag = true;
                    }
                    so.$apply();
                });
            }

            so.startTask = function() {
                steveConfrim("确定启动任务吗?", function() {
                    $.post("startTask", function(data) {
                        if (data == 'true') {
                            steveAl("操作成功", 1000);
                        } else {
                            steveAl("操作失败", 1000);
                        }

                    });
                }, true);

            }

            so.closeTask = function() {
                steveConfrim("确定关闭任务吗?", function() {
                    $.post("closeTask", function(data) {
                        if (data == 'true') {
                            steveAl("操作成功", 1000);
                        } else {
                            steveAl("操作失败", 1000);
                        }

                    });
                }, true);

            }
            so.restartTask = function() {
                steveConfrim("确定启动任务吗?", function() {
                    $.post("restartTask", function(data) {
                        if (data == 'true') {
                            steveAl("操作成功", 1000);
                        } else {
                            steveAl("操作失败", 1000);
                        }

                    });
                }, true);

            }
            so.getConfig();

        })

